//package excel;
//
//
//
//import org.apache.poi.xssf.usermodel.XSSFCell;
//import org.apache.poi.xssf.usermodel.XSSFRow;
//import org.apache.poi.xssf.usermodel.XSSFSheet;
//import org.apache.poi.xssf.usermodel.XSSFWorkbook;
//import sql.MysqlDemo;
//
//import java.io.*;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.stream.Collectors;
//
//
///**
// * todo
// *
// * @author zhengshan
// * @Date 2022/12/29 9:49
// */
//public class TestExcelDemo {
//
//
////    public static class ExportBlackCodeFee {
////        public void readExcel(String path) throws IOException {
////            // 获取文件流
////            InputStream is = new FileInputStream(path);
////            HSSFWorkbook hssfWorkbook = new HSSFWorkbook(is);
////            // 获取所有sheet
//////            for (int numSheet = 0; numSheet < hssfWorkbook.getNumberOfSheets(); numSheet++) {
////                HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(1);
//////                if (hssfSheet == null) {
//////                    continue;
//////                }
////                // 处理一个sheet。第一行是字段名称,直接跳过，所以rowNum从1开始
////                for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
////                    HSSFRow hssfRow = hssfSheet.getRow(rowNum);
////                    if (hssfRow != null) {
////                        // 2.通道name.String类型
////                        HSSFCell blackCodeNameCell1 = hssfRow.getCell(1);
////                        String blackCodeName1 = blackCodeNameCell1.getStringCellValue();
////                        System.out.println(blackCodeName1);;
////
////                        // 2.通道name.String类型
////                        HSSFCell blackCodeNameCell2 = hssfRow.getCell(2);
////                        String blackCodeName2 = blackCodeNameCell2.getStringCellValue();
////                        System.out.println(blackCodeName2);;
////
////
////                    }
////                }
////
//////            HSSFSheet hssfSheet2 = hssfWorkbook.getSheetAt(2);
//////            // 处理一个sheet。第一行是字段名称,直接跳过，所以rowNum从1开始
//////            for (int rowNum = 1; rowNum <= hssfSheet2.getLastRowNum(); rowNum++) {
//////                HSSFRow hssfRow = hssfSheet2.getRow(rowNum);
//////                if (hssfRow != null) {
//////                    // 2.通道name.String类型
//////                    HSSFCell blackCodeNameCell = hssfRow.getCell(2);
//////                    String blackCodeName = blackCodeNameCell.getStringCellValue();
//////                    System.out.println(blackCodeName);;
//////                }
//////            }
//////            }
////        }
////
////    }
//
//    public static void main(String[] args) throws IOException {
//        try {
//
//            readExecl("C:\\Users\\admin\\Desktop\\百胜\\百胜三期\\数据清洗\\20230418\\Result_17.xlsx");
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }
//
//    //读取excel表格中的数据，path代表excel路径
//    public static void readExecl(String path) {
//        MysqlDemo mysqlDemo = new MysqlDemo();
//        try {
//            //读取的时候可以使用流，也可以直接使用文件名
//            XSSFWorkbook xwb = new XSSFWorkbook(path);
//            //循环工作表sheet
////            List<DwbiDto> dwbiDtos = new ArrayList<>();
////            List<ItemInfoDemo> itemInfoDemos = new ArrayList<>();
//            List<CanTingDto> canTingDtos = new ArrayList<>();
//            for (int numSheet = 0; numSheet < xwb.getNumberOfSheets(); numSheet++) {
//                XSSFSheet xSheet = xwb.getSheetAt(numSheet);
//                if (xSheet == null) {
//                    continue;
//                }
//                //循环行row
//                for (int numRow = 0; numRow <= xSheet.getLastRowNum(); numRow++) {
//                    XSSFRow xRow = xSheet.getRow(numRow);
//                    if (xRow == null) {
//                        continue;
//                    }
////                    if(numSheet == 0) {
////                        DwbiDto dwbiDto = new DwbiDto();
////                        dwbiDto.setEspBrand(getValue(xRow.getCell(0)).replace(" ", ""));
////                        dwbiDto.setProductCode(getValue(xRow.getCell(1)).replace(" ", ""));
////                        dwbiDto.setBrand(getValue(xRow.getCell(2)).replace(" ", ""));
//////                        dwbiDto.setDwbiProductCode(getValue(xRow.getCell(0)).replace(" ", ""));
//////                        dwbiDto.setMcItemcode(getValue(xRow.getCell(2)).replace(" ", ""));
////                        dwbiDto.setDwbiProductCode(getValue(xRow.getCell(3)).replace(" ", ""));
////                        dwbiDto.setProductName(getValue(xRow.getCell(4)).replace(" ", ""));
////                        mysqlDemo.insert(dwbiDto.toString());
////                    }
//
//                    if(numSheet == 0) {
//                        Result20230418 b = new Result20230418();
//                        /**
//                         brand;
//                         itemCode;
//                         standardProductCode;
//                         e;
//                         subclassdesc;
//                         classdesc;
//                         subcategorydesc;
//                         categorydesc;
//                         */
//
//                        b.setBrand(getValue(xRow.getCell(0)).replace(" ", ""));
//                        b.setItemCode(getValue(xRow.getCell(1)).replace(" ", ""));
//                        b.setStandardProductCode(getValue(xRow.getCell(2)).replace(" ", ""));
//                        b.setE(getValue(xRow.getCell(3)).replace(" ", ""));
//                        b.setSubclassdesc(getValue(xRow.getCell(4)).replace(" ", ""));
//                        b.setClassdesc(getValue(xRow.getCell(5)).replace(" ", ""));
//                        b.setSubcategorydesc(getValue(xRow.getCell(6)).replace(" ", ""));
//                        b.setCategorydesc(getValue(xRow.getCell(7)).replace(" ", ""));
//
//
//
//
////                        /**
////                         * brandNummateProductCode;
////                         * mateProductName;
////                         * mappingMappingDWBIProductCode;
////                         * itemCode;
////                         * recipeCode;
////                         * recipeName;
////                         * productFgCode;
////                         * bomProductCode;
////                         * recipeNums;
////                         * bomMaterialCode;
////                         */
////                        b.setBrandNummateProductCode(getValue(xRow.getCell(0)).replace(" ", ""));
////                        b.setMateProductName(getValue(xRow.getCell(1)).replace(" ", ""));
////                        b.setMappingMappingDWBIProductCode(getValue(xRow.getCell(2)).replace(" ", ""));
////                        b.setItemCode(getValue(xRow.getCell(3)).replace(" ", ""));
////                        b.setRecipeCode(getValue(xRow.getCell(4)).replace(" ", ""));
////                        b.setRecipeName(getValue(xRow.getCell(5)).replace(" ", ""));
////                        b.setProductFgCode(getValue(xRow.getCell(6)).replace(" ", ""));
////                        b.setBomProductCode(getValue(xRow.getCell(7)).replace(" ", ""));
////                        b.setRecipeNums(getValue(xRow.getCell(8)).replace(" ", ""));
////                        b.setBomMaterialCode(getValue(xRow.getCell(9)).replace(" ", ""));
////                        b.setMateproductcode(getValue(xRow.getCell(10)).replace(" ", ""));
//
////                        ProductMapping p = new ProductMapping();
////                        /**
////                         * espBrand;
////                         * productFgCode;
////                         * dwbiBrand;
////                         * dwbiProductCode;
////                         * orclCreateDate;
////                         */
////                        p.setEspBrand(getValue(xRow.getCell(0)).replace(" ", ""));
////                        p.setProductFgCode(getValue(xRow.getCell(1)).replace(" ", ""));
////                        p.setDwbiBrand(getValue(xRow.getCell(2)).replace(" ", ""));
////                        p.setDwbiProductCode(getValue(xRow.getCell(3)).replace(" ", ""));
////                        p.setOrclCreateDate(getValue(xRow.getCell(4)).replace(" ", ""));
//
//
//
////                        Dining794Dto ss = new Dining794Dto();
////                        ss.setId(Long.valueOf(getValue(xRow.getCell(0)).replace(" ", "").substring(0, getValue(xRow.getCell(0)).replace(" ", "").indexOf("."))));
////                        ss.setJdeCode(getValue(xRow.getCell(1)).replace(" ", ""));
////                        ss.setJdeName(getValue(xRow.getCell(2)).replace(" ", ""));
////                        ss.setPurchaseTypeCode(getValue(xRow.getCell(3)).replace(" ", ""));
////                        ss.setPurchaseTypeName(getValue(xRow.getCell(4)).replace(" ", ""));
////                        ss.setBrandCode(getValue(xRow.getCell(5)).replace(" ", ""));
////                        ss.setBasicmaterialCode(getValue(xRow.getCell(6)).replace(" ", ""));
////                        ss.setBasicmaterialName(getValue(xRow.getCell(7)).replace(" ", ""));
////
////                        ss.setBasicmaterialTypeCode(getValue(xRow.getCell(8)).replace(" ", ""));
////                        ss.setRecipeUnitCode(getValue(xRow.getCell(9)).replace(" ", ""));
////                        ss.setRecipeUnitName(getValue(xRow.getCell(10)).replace(" ", ""));
//
////
////                        ss.setBasicmaterialTypeCode(getValue(xRow.getCell(8)).replace(" ", ""));
////                        ss.setBasicmaterialType(getValue(xRow.getCell(9)).replace(" ", ""));
//                        mysqlDemo.insertTestDining20230309Info(b.toString());
//
////                        canTingDtos.add(ss);
////                        private String brandCode;
////
////                        private String brandDescr;
////
////                        private String jdeCode;
////
////                        private String jdeName;
////
////                        private String basicmaterialCode;
////
////                        private String basicmaterialName;
////
////                        private String recipeUnitCode;
////
////                        private String unitName;
////
////                        private String basicmaterialTypeCode;
////
////                        private String basicmaterialType;
//
//
////                        itemInfoDemo1.setDwbiProductCode(getValue(xRow.getCell(0)).replace(" ", ""));
////                        itemInfoDemo1.setMcName(getValue(xRow.getCell(3)).replace(" ", ""));
//                    }
////                    if(canTingDtos.size() >= 300) {
////                        mysqlDemo.insertDiningInfo(canTingDtos);
////                        canTingDtos.clear();
////                    }
//
////                    //循环列cell
////                    for (int numCell = 0; numCell <= xRow.getLastCellNum(); numCell++) {
////                        XSSFCell xCell = xRow.getCell(numCell);
////                        if (xCell == null) {
////                            continue;
////                        }
////                        //输出值
////                        System.out.println("excel表格中取出的数据" + getValue(xCell));
////                    }
//                }
////                mysqlDemo.insertDiningInfo(canTingDtos);
//            }
////            StringBuffer str = new StringBuffer();
////            int i = 0;
////            int leng = 0;
////            int j = 0;
////            List<ItemInfoDemo> itemInfoDemos1 = new ArrayList<>();
//////            itemInfoDemos1 = itemInfoDemos.stream().distinct().collect(Collectors.toList());
////            for(DwbiDto dwbiDto : dwbiDtos){
//////                if(j == 0){
//////                    str.append(dwbiDto.toString() + "\r\n");
//////                    j++;
//////                }
////                for(ItemInfoDemo itemInfoDemo : itemInfoDemos){
//////                    if("老坛酸菜鱼炒饭".equals(dwbiDto.getProductName()) && "老坛酸菜鱼炒饭".equals(itemInfoDemo.getMcName())){
//////                        i = 123;
//////                    }
//////                    if(null == dwbiDto.getProductName()){
//////                        continue;
//////                    }
//////                    if(dwbiDto.toString().equals(itemInfoDemo.toString())){
//////                    }
////
////                    if(itemInfoDemo.getMcItemcode().equals(dwbiDto.getDwbiProductCode()) && "KFC".equals(dwbiDto.getBrand())){
////
////                        dwbiDto.setMcItemcode(itemInfoDemo.getMcItemcode());
////                        dwbiDto.setMcName(itemInfoDemo.getMcName());
////                        dwbiDto.setsProductCode(itemInfoDemo.getProductCode());
//////                        itemInfoDemo.setDwbiProductCode(dwbiDto.getDwbiProductCode());
//////                        itemInfoDemo.setBrand(dwbiDto.getBrand());
////                    }
////                }
////                str.append(dwbiDto.toString() + "\r\n");
////                if(leng >= 15000){
////                    exportText(str.toString(), i);
////                    str.setLength(0);
////                    i++;
////                    leng = 0;
////                }
//////                leng++;
////            }
//////            for(ItemInfoDemo itemInfoDemo : itemInfoDemos){
//////                if(null == itemInfoDemo.getDwbiProductCode()) {
//////                    str.append(itemInfoDemo.toString() + "\r\n");
//////                }
//////            }
////            exportText(str.toString(), i);
//
//
//
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
//
//    public static void exportText(String text, int i) {
//        try {
//            File f = new File("C:\\Users\\admin\\Desktop\\百胜\\百胜三期\\数据清洗\\合并 "+i+".text");
//            FileOutputStream fos1 = new FileOutputStream(f);
//            OutputStreamWriter dos1 = new OutputStreamWriter(fos1);
//            dos1.write(text);
//            dos1.close();
//        }catch (Exception e){
//
//        }
//    }
//
//
//    /**
//     * 取出每列的值
//     *
//     * @param xCell 列
//     * @return
//     */
//    public static String getValue(XSSFCell xCell) {
//        if(null != xCell) {
//            if (xCell.getCellType() == XSSFCell.CELL_TYPE_BOOLEAN) {
//                return String.valueOf(xCell.getBooleanCellValue());
//            } else if (xCell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) {
//                return String.valueOf(xCell.getNumericCellValue());
//            } else {
//                return String.valueOf(xCell.getStringCellValue());
//            }
//        }
//        return "";
//    }
//
//
//
//
//}
